package hu.diploma.web.server.serviceimpl;

import hu.diploma.common.service.CallsService;
import hu.diploma.common.vos.CallVo;
import hu.diploma.core.util.ServiceProviderImpl;
import hu.diploma.web.client.service.WebCallService;
import hu.diploma.web.shared.webvos.CallWebVo;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class WebCallServiceImpl extends RemoteServiceServlet implements WebCallService {
	CallsService callsService = ServiceProviderImpl.getServiceProvider().getCallService();

	public List<CallWebVo> loadAll() throws Exception {
		List<CallWebVo> callWebVos = new ArrayList<CallWebVo>();

		List<CallVo> callVos = callsService.loadAll();
		for (CallVo callVo : callVos) {
			CallWebVo callWebVo = new CallWebVo();
			callWebVo.setDate(callVo.getDate());
			callWebVo.setDuration(callVo.getDuration());
			callWebVo.setName(callVo.getName());
			callWebVo.setNumber(callVo.getNumber());
			callWebVos.add(callWebVo);
		}
		return callWebVos;
	}

}
